

var iTanggalM = 0; 
var iTanggalH = 0; 
var iBulanM = 0; 
var iBulanH = 0; 
var iTahunM = 0; 
var iTahunH = 0; 
var iTahunJ = 0; 

function intPart(floatNum) { 
  return(floatNum<-0.0000001? Math.ceil(floatNum-0.0000001) : Math.floor(floatNum+0.0000001)); 
} 


// 32075+1 disesuaikan untuk menambah atau mengurangi sesuai pengumuman pemerintah

function hitung_Hijriah(d,m,y) { 
  mPart = (m-13)/12; 
  jd = intPart((1461*(y+4800+intPart(mPart)))/4)+ 
       intPart((367*(m-1-12*(intPart(mPart))))/12)- 
       intPart((3*(intPart((y+4900+intPart(mPart))/100)))/4)+d-32075+1; 

  l = jd-1948440+10632; 
  n = intPart((l-1)/10631); 
  l = l-10631*n+354; 

// 29+1 disesuaikan untuk menambah atau mengurangi sesuai pengumuman pemerintah
  j = (intPart((10985-l)/5316))*(intPart((50*l)/17719))+(intPart(l/5670))*(intPart((43*l)/15238)); 
  l = l-(intPart((30-j)/15))*(intPart((17719*j)/50))-(intPart(j/16))*(intPart((15238*j)/43))+29; 

  iBulanH = intPart((24*l)/709); 
  iTanggalH = l-intPart((709*iBulanH)/24); 
  iTahunH = 30*n+j-30; 
  iBulanH -= 1; 
} 

function hitung_Tanggal(format) { 

  var namaBulanE = new Array( "January","February","March","April","May","June","July","August","September","October","November","December"); 
  var namaBulanH = new Array( "Muharram","Safar","Rabi Al-Awwal","Rabi Al-Thani","Jumada Al-Ula","Jumada Al-Thani","Rajab","Shaban","Ramadhan","Shawwal","Dhul Qada","Dhul Hijja"); 
  var namaBulanI = new Array( "Januari","Februari","Maret","April","Mei","Juni","Juli","Agustus","September","Oktober","November","Desember"); 
  var namaBulanHI = new Array( "Muharram","Safar","Rabi'ul Awal","Rabi'ul Akhir","Jumadil Awal","Jumadil Akhir","Rajab","Sya'ban","Ramadhan","Syawal","Dzulqa'dah","Dzulhijjah"); 
  var namaBulanJ = new Array( "Suro","Sapar","Mulud","Ba'da Mulud","Jumadil Awal","Jumadil Akhir","Rejeb","Ruwah","Poso","Syawal","Dulkaidah","Besar"); 

  var namaHariE = new Array("Thursday","Friday","Saturday","Sunday","Monday","Tuesday","Wednesday"); 
  var namaHariH = new Array("Al-Hamis","Al-Jum'a","As-Sabt","Al-Ahad","Al-Itsnayna","Ats-Tsalatsa'","Al-Arba'a'"); 
  var namaHariI = new Array("Kamis","Jumat","Sabtu","Ahad","Senin","Selasa","Rabu"); 
  var namaHariJ = new Array("Wage","Kliwon","Legi","Pahing","Pon","Wage","Kliwon"); 

  now = new Date(); 

  iTanggalM = now.getDate(); 
  iBulanM = now.getMonth(); 
  iTahunM = now.getYear(); 
  if(iTahunM<1900) { iTahunM += 1900 }; // Y2K 

  hitung_Hijriah(iTanggalM,iBulanM,iTahunM); 
  hr = Date.UTC(iTahunM,iBulanM,iTanggalM,0,0,0)/1000/60/60/24; 
  iTahunJ = iTahunH+512; 

  sHariE = namaHariE[hr%7];         //string nama hari : Inggris 
  sHariH = "Yaum "+namaHariH[hr%7]; //string nama hari : Arab 
  sHariI = namaHariI[hr%7];         //string nama hari : Indonesia 
  sHariJ = namaHariJ[hr%5];         //string nama hari : Jawa (hari pasar) 

  sBulanE = namaBulanE[iBulanM];    //string nama bulan : Masehi - Inggris 
  sBulanH = namaBulanH[iBulanH];    //string nama bulan : Hijriah - Arab 
  sBulanI = namaBulanI[iBulanM];    //string nama bulan : Masehi - Indonesia 
  sBulanHI = namaBulanHI[iBulanH];  //string nama bulan : Hijriah - Indonesia 
  sBulanJ = namaBulanJ[iBulanH];    //string nama bulan : Hijriah - Jawa 

  //iTanggalM : int tanggal Masehi (Inggris/Indonesia) 
  //iTanggalH : int tanggal Hijriah (Arab/Indonesia/Jawa) 

  zTanggalM = iTanggalM<10? "0"+iTanggalM : iTanggalM; //int tanggal Masehi (Inggris/Indonesia), + leading zero 
  zTanggalH = iTanggalH<10? "0"+iTanggalH : iTanggalH; //int tanggal Hijriah (Arab/Indonesia/Jawa), + leading zero 

  iBulanM += 1; //int bulan Masehi (Inggris/Indonesia) 
  iBulanH += 1; //int bulan Hijriah (Arab/Indonesia/Jawa) 

  zBulanM = iBulanM<10? "0"+iBulanM : iBulanM; //int bulan Masehi (Inggris/Indonesia), + leading zero 
  zBulanH = iBulanH<10? "0"+iBulanH : iBulanH; //int bulan Hijriah (Arab/Indonesia/Jawa), + leading zero 

  //iTahunM : int tahun Masehi (Inggris/Indonesia) 
  //iTahunH : int tahun Hijriah (Arab/Indonesia) 
  //iTahunJ : int tahun Jawa 

  //FORMAT : 
  //1 (default) (Indonesia)              : Selasa, 1 Januari 1980 
  //2           (English)                : Tuesday, 1 January 1980 
  //3           (Indonesia + hari pasar) : Selasa Legi, 1 Januari 1980 
  //4           (Jawa)                   : Selasa Legi, 12 Sapar 1912 
  //5           (Arab/Hijriah)           : Yaum Ats-Tsalatsa, 12 Safar 1400 H 
  //6           (Indonesia/Hijriah)      : Selasa, 12 Safar 1400 H 
  //7           (English + Jawa :P)      : Tuesday Legi, 12 Sapar 1912 
  //de-el-el...                          : masih banyak variasi... :D :D :D 

  switch(format) { 
    case 6 : { sDate = sHariE+", "+iTanggalM+" "+sBulanE+" "+iTahunM+" M";break; } 
    case 3 : { sDate = sHariI+" "+sHariJ+", "+iTanggalH+" "+sBulanJ+" "+iTahunJ;break; } 
    case 5 : { sDate = sHariH+", "+iTanggalH+" "+sBulanH+" "+iTahunH+" H";break; } 
    case 4 : { sDate = sHariI+", "+iTanggalH+" "+sBulanHI+" "+iTahunH+" H";break; } 
    case 2 : { sDate = "<span class='tgl1'>"+iTanggalM+" "+sBulanI+" "+iTahunM+" M</span>";break; } 
    case 7 : { sDate = "<span class='nHari'>"+sHariI+" "+sHariJ+"</span>"+", "+"<span class='ntglm'>"+iTanggalM+" "+sBulanI+" "+iTahunM+" M</span><br/><span class='ntglh'>"+iTanggalH+" "+sBulanHI+" "+iTahunH+" H</span>";break; } 
    default : { sDate = sHariI+", "+iTanggalM+" "+sBulanI+" "+iTahunM;break; } 

    case 8 : { sDate = "<span class='tgl1'>"+iTanggalM+" "+sBulanI+" "+iTahunM+" M</span><br/><span class='tgl2'>"+iTanggalH+" "+sBulanHI+" "+iTahunH+" H</span>";break; } 
    case 9 : { sDate = "<span class='dHari'>"+sHariI+" "+sHariJ+"</span>";break; }
  } 

  return(sDate); 
} 

function tulis_Tanggal(format) { 
  sDate = hitung_Tanggal(format); 
  document.write(sDate); 
} 

function buat_Dinten(format) { 
  sDate = hitung_Tanggal(format); 
  document.write(sDate); 
} 















/* Script Jam by Muhtar Hidayat 21 Maret 2011 */
var alternate=0
var standardbrowser=!document.all&&!document.getElementById

if (standardbrowser)
document.write('<form name="tick"><input type="text" name="tock" size="11"></form>')

function show(){
if (!standardbrowser)
var clockobj=document.getElementById? document.getElementById("digitalclock") : document.all.digitalclock
var Digital=new Date()
var hours=Digital.getHours()
var minutes=Digital.getMinutes()
var seconds=Digital.getSeconds ()

var dn="PM"
if (hours==24) 
dn="AM" 
if (hours<12)
{
var dn="AM"
if (hours==24) 
dn="PM" 
if (hours>12)
hours=hours-12
}
if (hours==0) hours=12
if (hours.toString().length==1)
hours="0"+hours

if (minutes<=9)
minutes="0"+minutes

if (seconds <= 9) 
seconds = "0"+seconds

if (standardbrowser){
if (alternate==0)
document.tick.tock.value=hours+":"+minutes+":"+seconds+" "+dn
else
document.tick.tock.value=hours+":"+minutes+":"+seconds+" "+dn
}
else{
if (alternate==0)
clockobj.innerHTML=hours+":"+minutes+":"+seconds+" "+dn
else
clockobj.innerHTML=hours+":"+minutes+":"+seconds+" "+dn
}
alternate=(alternate==0)? 1 : 0
setTimeout("show()",1000)
}
window.onload=show


